package br.ufrn.findabomb;

import br.ufrn.findabomb.model.Player;
import br.ufrn.findabomb.controller.*;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.view.View;

public class MainActivity extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        Button sairLogin = (Button) findViewById(R.id.sairLogin);
        Button cadastrarLogin = (Button) findViewById(R.id.cadastrarLogin);
        Button entrarLogin = (Button) findViewById(R.id.entrarLogin);
    
        sairLogin.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                        //EXIT
                }
        });
        
        cadastrarLogin.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, CadastroUsuario.class);
                startActivity(intent);
                }
        });
        
        entrarLogin.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                        String senha = ((EditText) findViewById(R.id.etPasswdLogin)).getText().toString();
                        String nome = ((EditText) findViewById(R.id.etNameLogin)).getText().toString();

                        Player p = PlayerFinder.login(nome, senha);
                        //if (p!=null) {
                        Intent intent = new Intent(MainActivity.this, MenuPrincipal.class);
                        startActivity(intent);
                        //}
                }
        });        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}
